from sqlalchemy import  String, DateTime, func, Integer 
from sqlalchemy.orm import mapped_column , Mapped 

from ..db.database import Base 



class User(Base): 
    __tablename__ = 'user'
    id: Mapped[int]= mapped_column(Integer, primary_key=True, autoincrement=True, index=True)
    # 用户名称
    username = mapped_column(String(20))
    # 用户密码
    password = mapped_column(String(32))
    # 用户创建时间
    created_at = mapped_column(DateTime(), default=func.now())


class ShortUrl(Base): 
    __tablename__ = 'short_url'
    id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True,index=True)
    # 超链标签
    short_tag = mapped_column(String(20), nullable=False)
    # 超链地址
    short_url = mapped_column(String(20))
    # 长链地址
    long_url = mapped_column(String, nullable=False)
    # 访问次数
    visits_count: Mapped[int] = mapped_column(Integer, nullable=True)
    # 超链创建时间 
    created_at = mapped_column(DateTime(), default=func.now(), )
    # 超链创建用户 
    created_by = mapped_column(String(20))
    # 短信内容
    msg_context = mapped_column(String, nullable=False, )

                        



